package com.headwind.logistics.prople.controller;

import com.headwind.logistics.common.pojo.Customer;
import com.headwind.logistics.common.util.LayuiUtil;
import com.headwind.logistics.prople.service.inter.CustomersServiceInter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author Gu1028
 * @Date 2020/7/20 10:35
 * @Version 1.0
 * @DESCRIPTION 顾客控制器层
 */
@Controller
public class CustomersController {


    //部门业务逻辑层接口
    @Resource
    private CustomersServiceInter customersServiceInter;


    /**
     * 获取分页部门信息
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("/admin/prople/selectAllCustomer")
    @ResponseBody
    public LayuiUtil selectAllCustomer(Integer page, Integer limit){
        //获取分页部门
        List<Customer> customer = customersServiceInter.selectAllCustomer(page, limit);



        return LayuiUtil.data(customersServiceInter.selectAllCustomer(page,limit).size(),customer);
    }

    /**
     * 根据员工id修改员工状态
     * @param customer
     * @return
     */
    @PostMapping("/admin/prople/updateCustomerByCustId")
    @ResponseBody
    public int updateCustomerByCustId(Customer customer){

        System.out.println(1111);
        int count = customersServiceInter.updateCustomerByCustId(customer);

        return count;


}
    /**
     * 根据姓名、性别、手机号 搜索顾客
     * @param customer
     */
    @GetMapping("/admin/prople/queryCustomerByNameOrSexOrPhoneOrStatus")
    @ResponseBody
    public LayuiUtil queryCustomerByNameOrSexOrPhoneOrStatus(Customer customer, Integer page, Integer limit) {
        //获取分页部门
        List<Customer> customers = customersServiceInter.queryCustomerByNameOrSexOrPhoneOrStatus(customer,page, limit);

        for (Customer as:customers
        ) {
            System.out.println(as.getUserName());
        }

        return LayuiUtil.data(customersServiceInter.queryCustomerByNameOrSexOrPhoneOrStatus(customer,page,limit).size(),customers);
    }
}